package com.workmanager.service;

import com.workmanager.bean.ClassBean;
import com.workmanager.bean.StudentBean;
import com.workmanager.mapper.TeacherClassMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by liao on 2016/8/24.
 */

@Service("TeacherClassService")
public class TeacherClassService {
    @Resource(name="teacherClassMapper")
    private TeacherClassMapper teacherClassMapper;

    public TeacherClassMapper getTeacherClassMapper() {
        return teacherClassMapper;
    }

    public void setTeacherClassMapper(TeacherClassMapper teacherClassMapper) {
        this.teacherClassMapper = teacherClassMapper;
    }
    public List<ClassBean> getAllClassesByTeacherId(String teacherId){
        List<ClassBean> list = new ArrayList<ClassBean>();
        list = teacherClassMapper.getAllClassesByTeacherId(teacherId);
        return list;
    }
    public boolean saveClassInformation(Map map){
        int a = teacherClassMapper.saveClassInformation(map);
        System.out.println("change"+a);
        return a>0;
    }
    public boolean delClass(int classId){
         int result1 = teacherClassMapper.delTeacherClass(classId);
        int result2 = teacherClassMapper.delClass(classId);
        return result1>0&result2>0;
    }
    public List<StudentBean> getStuClassByClassId(int class_id){
        return teacherClassMapper.getStuClassByClassId(class_id);
    }
    public boolean addClass(Map<String,String> map){
        int result1 = teacherClassMapper.addClass(map);
       // System.out.println(map.get("class_id"));
        int  result2 = teacherClassMapper.addTeacherClass(map);
        return result1>0&&result2>0;
    }
    public boolean delStudent(Map map){
        return  teacherClassMapper.delStudent(map)>0;
    }
    public StudentBean getStudentInformation(Map map){
        return teacherClassMapper.getStudentInformation(map);
    }
    public boolean addRemarks(Map map){
        return teacherClassMapper.addRemarks(map)>0;
    }
}